package com.example.cofeed.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.ObjectUtils;
import  com.example.cofeed.util.ToastUtils;;
import com.example.cofeed.MainActivity;
import com.example.cofeed.R;
import com.example.cofeed.api.ApiService;
import com.example.cofeed.base.BaseActivity;
import com.example.cofeed.callback.DialogCallback;
import com.example.cofeed.callback.LzyResponse;
import com.lzy.okgo.model.Response;
import com.umeng.analytics.MobclickAgent;

import butterknife.BindView;
import butterknife.OnClick;

public class FeedbackActivity extends BaseActivity {

    @BindView(R.id.rb_search)
    RadioButton mRbSearch;
    @BindView(R.id.rb_pay)
    RadioButton mRbPay;
    @BindView(R.id.rb_kf)
    RadioButton mRbKf;
    @BindView(R.id.rb_hyxg)
    RadioButton mRbHyxg;
    @BindView(R.id.rb_shouhou)
    RadioButton mRbShouhou;
    @BindView(R.id.rb_qita)
    RadioButton mRbQita;
    @BindView(R.id.sex_rg)
    RadioGroup mSexRg;
    @BindView(R.id.et_content)
    EditText mEtContent;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_feedback;
    }

    @Override
    protected void init(Bundle savedInstanceState, View container) {
        setMainTitle("意见反馈");

    }

    @OnClick(R.id.confirm_tv)
    public void onViewClicked() {
        String content = mEtContent.getText().toString().trim();
        if (ObjectUtils.isEmpty(content)){
            ToastUtils.showShort("请输入您的建议");
            return;
        }
        int type = 0;
        if (mRbSearch.isChecked()){
            type = 1;
        }else if (mRbPay.isChecked()){
            type = 2;
        }else if (mRbKf.isChecked()){
            type = 3;
        }else if (mRbHyxg.isChecked()){
            type = 4;
        }else if (mRbShouhou.isChecked()){
            type = 5;
        }else if (mRbQita.isChecked()){
            type = 6;
        }

        ApiService.suggestion_add(this, type, content, new DialogCallback<LzyResponse<Object>>(this) {
            @Override
            public void onSuccess(Response<LzyResponse<Object>> response) {
                showToast();
                finish();
            }
        });

    }

    @Override
    public void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
    }

    @Override
    public void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
    }
}
